import UserModel from '../models/userdata'

class HomeService {
	async index (ctx: any) {
		UserModel.findOne({ user_name: 123 }).then(res => console.log(res)).catch(err => console.log(err))
		const user = new UserModel({
			user_name: 'yangbo',
			user_password: '1234'
		})
		try {
			const { _id: uid } = await user.save()
			ctx.body = {
				code: 10000,
				message: 'ok',
				body: { uid }
			}
		} catch (error) {
			ctx.body = {
				code: 10004,
				message: error,
				body: {}
			}
		}
	}
}

export default new HomeService